fix: add cross-platform build support for darwin and windows#44
fix: add cross-platform build support for darwin and windows#44colin-rushton-qss wants to merge 2 commits into
Conversation
Extract platform-specific code behind build tags so the full module compiles on linux, darwin, and windows: - addons/bootstrap: user-groups_other.go stub for non-linux - addons/diags: split stat-times into _linux.go + _other.go, fix dead code bug (value→pointer type assertion on Stat_t) - addons/pm/server: split process group ops into proc_linux.go + proc_other.go - lib/sys: add daemon_other.go FallbackLogFileEnv constant
|
|
||
| // SetVersion overrides the main version string reported by Version() and | ||
| // VersionInfo(). Call before any use of the version functions. | ||
| func SetVersion(v string) { |
There was a problem hiding this comment.
Can you explain the use case for this? The normal Go build process should put your VCS info into the binary, right?
There was a problem hiding this comment.
Sorry, I need to pull that out, I pushed on the wrong branch, I was trying to fix an issue where the VCS would show in 2 different ways depending on how it was set and it was confusing because sometimes it would show mine, and sometimes it would show the gdev one. The override I tried doing didn't resolve it, but there's probably a better way to handle it regardless, it shouldn't be upstream.
There was a problem hiding this comment.
The main module info should definitely only ever show yours, unless you're building e.g. the "gdev" example :)
| // On non-Linux platforms, Uid, Gid, AccessTime, and ChangeTime | ||
| // are left at their zero values. Darwin uses different syscall.Stat_t | ||
| // field names (Atimespec/Ctimespec) and Windows has no syscall.Stat_t. |
There was a problem hiding this comment.
Should at least be able to put together a reasonable implementation for Darwin? I don't know off the top of my head what the "Sys" stat structure is for Windows though
| func terminateProcessGroup(_ int) error { | ||
| return fmt.Errorf("process group termination not supported on %s", runtime.GOOS) | ||
| } | ||
|
|
||
| func killProcessGroup(_ int) error { | ||
| return fmt.Errorf("process group kill not supported on %s", runtime.GOOS) | ||
| } |
There was a problem hiding this comment.
Doesn't the process group thing work on Darwin?
There was a problem hiding this comment.
It was failing when I tried cross-compiling, but I'll dig into it more to try to get a true/proper fix.
| // a fallback log file path for daemons started without systemd support. | ||
| // | ||
| // This will not be passed to the actual daemon. | ||
| const FallbackLogFileEnv = "__FALLBACK_LOG_FILE" |
There was a problem hiding this comment.
This should probably just go into daemon.go (new file) instead of having platform-specific copies. Probably over time other non-platform-specific bits will accumulate.
|
One more item: while I don't see the need for artifact publishing for macOS and Windows, adding basic "does it compile" checks to them in CI (GHA) would be a good idea here. |
Extract platform-specific code behind build tags so the full module compiles on linux, darwin, and windows: